package edu.gdkm.sql.dao;

import edu.gdkm.sql.pojo.Order;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface OrderMapper {

    // 查询全部订单
    @Select("SELECT * FROM `order`")

    List<Order> findAll();

    // 根据id查询订单
    @Select("SELECT * FROM `order` WHERE id = #{id}")

    Order findById(int id);

    // 根据用户id查询订单
    @Select("SELECT * FROM `order` WHERE userinfoid = #{userinfoid}")

    List<Order> findByUserinfoid(int id);

    // 插入订单
    @Insert("INSERT INTO `order`(userinfoid, orderdate) VALUES(#{userinfoid}, #{orderdate})")

    int insertOrder(Order order);

    // 更新订单
    @Update("UPDATE `order` SET userinfoid=#{userinfoid}, orderdate=#{orderdate} WHERE id=#{id}")

    int updateOrderById(Order order);

    // 删除订单
    @Delete("DELETE FROM `order` WHERE id=#{id}")

    int deleteOrderById(int id);
}